import request from "@/utils/request";

export default {
  //搜索学生
  adminSearchStudent(currentPage, limit, searchStudentVo) {
    return request({
      url: "/studentInfo/getStudentsBySelector",
      method: "post",
      data: searchStudentVo,
      params: { currentPage, limit },
    });
  },
  //插入学生
  adminInsetStudent(studentInfo) {
    return request({
      url: "/studentInfo/insertStudent",
      method: "post",
      data: studentInfo,
    });
  },
  //更新学生的权限
  updateIsAdmin(isAdmin, studentId) {
    return request({
      url: "/studentInfo/updateIsAdmin",
      method: "put",
      params: {
        isAdmin,
        studentId,
      },
    });
  },
  //更改是否禁言
  updateIsForbidden(isForbidden, studentId) {
    return request({
      url: "/studentInfo/updateIsForbidden",
      method: "put",
      params: {
        isForbidden,
        studentId,
      },
    });
  },

  //插入教师
  adminInsetTeacher(teacherInfo) {
    return request({
      url: "/teacherInfo/addTeacher",
      method: "post",
      params: {
        teacherId: teacherInfo.teacherId,
        name: teacherInfo.name,
        unit: teacherInfo.unit,
        occupation: teacherInfo.occupation,
      },
    });
  },
  //搜索教师
  adminSearchTeacher(currentPage, limit, searchTeacherVo) {
    return request({
      url: "/teacherInfo/getByPage",
      method: "post",
      data: searchTeacherVo,
      params: { currentPage, limit },
    });
  },
  //更改教师权限
  updateTeacherIsAdmin(changedAdmin, teacherId) {
    return request({
      url: "/teacherInfo/changeAdmin",
      method: "post",
      params: {
        changedAdmin,
        teacherId,
      },
    });
  },
  //更改教师是否禁言
  updateTeacherIsForbidden(changedStatus, teacherId) {
    return request({
      url: "/teacherInfo/changeStatus",
      method: "post",
      params: {
        changedStatus,
        teacherId,
      },
    });
  },
  //撤回文章操作
  deleteByArticleId(articleId) {
    return request({
      url: "/forum/deleteByArticleId",
      method: "delete",
      params: {
        articleId,
      },
    });
  },
  deleteByCommentId(commentId) {
    return request({
      url: "/comment/deleteByCommentId",
      method: "delete",
      params: {
        commentId,
      },
    });
  },
  //用户举报管理
  saveUserTipOff(description, informeduserId) {
    return request({
      url: "/tipoff/usertipoff",
      method: "post",
      params: {
        description,
        informeduserId,
      },
    });
  },
  //评论举报管理
  saveCommentTipOff(commentId, description) {
    return request({
      url: "/tipoff/commentipoff",
      method: "post",
      params: {
        commentId,
        description,
      },
    });
  },
  //文章举报管理
  saveArticleTipOff(articleId, description) {
    return request({
      url: "/tipoff/articletipoff",
      method: "post",
      params: {
        articleId,
        description,
      },
    });
  },

  loadCommentsByUserName(username, pageNo, pageSize) {
    return request({
      url: "/comment/loadCommentsByPage",
      method: "get",
      params: {
        username,
        pageNo,
        pageSize,
      },
    });
  },

  getAllTipOff(type, searchType, pageNo, pageSize) {
    return request({
      url: "/tipoff/getAllTipoff",
      method: "get",
      params: {
        type,
        searchType,
        pageNo,
        pageSize,
      },
    });
  },

  ignoreTipOff(tipoffId, informedUserId, type) {
    return request({
      url: "/tipoff/ignore",
      method: "delete",
      params: {
        tipoffId,
        informedUserId,
        type,
      },
    });
  },

  starArticle(articleId, type) {
    return request({
      url: "/forum/starArticle",
      method: "post",
      params: {
        articleId,
        type,
      },
    });
  },
  topArticle(articleId, type) {
    return request({
      url: "/forum/topArticle",
      method: "post",
      params: {
        articleId,
        type,
      },
    });
  },
  deleteByArticleId(articleId) {
    return request({
      url: "/forum/deleteByArticleId",
      method: "delete",
      params: {
        articleId,
      },
    });
  },
};
